function table = confusion_table(cfm, label)

%    Returns a confusion table in the following format:
%    [[true positives, false negatives],
%     [false positives, true negatives]]
%    for the given label index in the confusion matrix.
    
    predicted = cfm(label, :);
    actual    = sum(cfm(:, label));
    true_pos  = predicted(label);
    false_pos = actual - true_pos;
    false_neg = sum(predicted) - true_pos;
    total     = sum(cfm(:));
    true_neg  = sum(total - true_pos - false_pos - false_neg);
    table     = [[true_pos false_neg];
                 [false_pos true_neg]];
end